<%@ page language="java" pageEncoding="utf-8" errorPage="errorPage.jsp" %>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>

<%  
  org.apache.struts.util.TokenProcessor.getInstance().saveToken(request);  
  %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
  <head>
    <html:base />
    
    <title>用户注册</title>

	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	
	<link href="css/iStyles.css" rel="stylesheet" type="text/css" />
	
	<script language="javascript" type="text/javascript">
	<%if (request.getAttribute("error") != null){%>alert("<%=request.getAttribute("error")%>");<%request.removeAttribute("error");}%>
	function checkLogin(login) {
		alert(11);
		if (login.usernameL.value == "")
		{
			alert("用户名不能为空");
			return false;
		}
		if (login.pswL.value =="")
		{
		    alert("密码不能为空");
		    return false;
		}
		return login.submit();
	}
	
	function Mycheck(register){
		if (register.username.value == "") {
			alert("用户名不能为空！！");
			return false;
		}
		if (register.realname.value == "") {
			alert("真实的姓名不能为空！！");
			return false;
		}
		if (register.psw.value == "") {
			alert("密码不能为空！！");
			return false;
		}
		if (register.psw2.value == "") {
			alert("确认密码不能为空！！");
			return false;
		}
		if (register.psw.value != register.psw2.value) {
			alert('您两次输入的密码不一致！');
			return false;
		}
		if (register.phone.value == "") {
			alert("联系电话不能为空！！");
			return false;
		}
		if (isNaN(register.phone.value)) {
			alert("联系电话必须为数字型！！");
			return false;
		}
		if (register.email.value == "") {
			alert("email不能为空，请填写正确的邮件！！");
			return false;
		}
		var i = register.email.value.indexOf("@")
		var j = register.email.value.indexOf(".")
		if ((i < 0) || (i - j > 0) || (j < 0)){
			alert("您输入的Email格式不正确，请重新输入！！");
			return false;
		}
		return register.submit();
		}
		</script>
<script type="text/javascript">
	function onlyNum(e){
		 var event = window.event || e;
    	 var key = document.all ? event.keyCode : event.which;
    	 return key >= 48 && key <= 57
	}
</script>
  </head>
  
  <body>
    	<!-- CONTAINER START -->
<div id = "container">
<!-- HEADER START -->
        <div id = "top">
        	<div id = "navigation">
        	    <html:link forward="go_to_index" styleClass="link">&nbsp;&nbsp;&nbsp;&nbsp;首页</html:link>
        	    <html:link forward="go_to_notice" styleClass="link">&nbsp;&nbsp;&nbsp;&nbsp;通知</html:link>
        	</div>
      	</div>
        <!-- HEADER END -->
        
        <!-- LOGIN START  --> 
        <form method="post" action="login.do" name="login" onsubmit="return checkLogin(login);">
        <input   type="hidden"   name="org.apache.struts.taglib.html.TOKEN" 
        	value="<%=session.getAttribute("org.apache.struts.action.TOKEN")%>"   /> 
        <div id = "login">
        		<div id = "username">
            		<label>用户名：</label><input type="text" name="usernameL" style="ime-mode:disabled"
            		onkeyup="value=value.replace(/[\W]/g,'') "
            		onkeydown="if(event.keyCode==13) event.keyCode=9"/>
            	</div>
            	<div id = "password">
   		  	  	  <label>密&nbsp;&nbsp;&nbsp;码 ：</label><input type="password" name="pswL"/>
       	      </div>
       	      <div id = "type">
       	         <br/>
       	      </div>
           	    <div id = "rememberPWD">
           		  	<input type="checkbox" name="rememberPWD" value="0" />记住密码&nbsp;
                	<a href="#" title="forget">忘记密码？</a>
   	 	        </div>
                <div id = "loginBt">
               	  	<input type="submit" name="loginBt" value="登录" class="btn"/>
                	<a href="register.do?method=init">注册</a>
              </div>
       	  
        </div>
        </form>
        <!-- LOGIN END   -->
        
        <!-- CLOCK START -->
  <div id = "clock">
        	<iframe src="index/clock.html" height="407" width="296" frameborder="0" scrolling="no"
            		marginheight="0" marginwidth="0" id="clockFrame" name="clockFrame"></iframe>
</div>
        <!-- CLOCK END -->
        
        <!-- MAIN START -->
        <form name="register" method="post" action="register.do?method=register" onSubmit="return Mycheck(register)">
        <input   type="hidden"   name="org.apache.struts.taglib.html.TOKEN" 
        	value="<%=session.getAttribute("org.apache.struts.action.TOKEN")%>"   /> 
        <div id = "main">
        	<div id = "register">
				<table class="t1" cellpadding="0" cellspacing="0">
  				<tr>
    				<td><b>≡ 用户注册 ≡</b></td>
    			</tr>
				</table>
				<table class="t2" cellpadding="0" cellspacing="0">
  				<tr>
    				<td height="332" class="td1">
						<table class="t3" cellspacing="0">
  						<tr>
    						<td>用 户 名: *</td>
    						<td><input name="username" type="text" 
    						onkeyup="value=value.replace(/[\W]/g,'') "
            				onkeydown="if(event.keyCode==13) event.keyCode=9"/></td>
  						</tr>
  						<tr>
    						<td>真实姓名: *</td>
    						<td><input name="realname" type="text" /></td>
  						</tr>
  						<tr>
    						<td>密 码: *</td>
    						<td><input name="psw" type="password" /></td>
  						</tr>
  						<tr>
    						<td>确认密码: *</td>
    						<td><input name="psw2" type="password" /></td>
  						</tr>
  						<tr>
    						<td>Email: *</td>
    						<td><input name="email" type="text" 
    						onkeyup="value=value.replace(/[^\a-\z\A-\Z0-9\@\.]/g,'')"></td>
  						</tr>
  						<tr>
    						<td>联系电话: *</td>
    						<td><input name="phone" type="text" onkeypress="return onlyNum(event);"></td>
                       	</tr>
						</table>
                        <center>
                        <input type="submit" name="Submit2" value="确定保存" />&nbsp;&nbsp;&nbsp;&nbsp;
  						<input type="reset" name="cancel" value="重新填写"/>&nbsp;&nbsp;&nbsp;&nbsp;
						</center>
                    </td>
  				</tr>
				</table>
			</div>
      </div>
      </form>	
   	<!-- MAIN END -->
        
   	<!-- FOOTER START -->
   	<div id = "footer">
  </div>
   	<!-- FOOTER END -->
        
  </div>
    <!-- CONTAINER END -->
    
  </body>
</html:html>
